package com.todolist.server.service;

import com.todolist.client.service.ProjectService;
import com.todolist.server.persistence.ProjectMapper;
import com.todolist.shared.domain.Project;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service("projectService")
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    ProjectMapper projectMapper;

    @Override
    public Project getProject(String name) {
        return projectMapper.getProject(name);
    }

    @Override
    public void addProject(String name) {
        projectMapper.addProject(name);
    }

    @Override
    public void updateProjectName(String oldName, String newName) {
        projectMapper.updateProjectName(oldName, newName);
    }

    @Override
    public void deleteProject(String name) {
        projectMapper.deleteProject(name);
    }

    @Override
    public ArrayList<Project> getProjects() {
        return (ArrayList) projectMapper.getProjects();
    }
}
